package com.benyi.util.bean;


public class PageReq<T> {
    int pageLength=20;
    int pageNo=1; //from 1
    int from;
    T query;
    
    public void setQuery(T q) {
    	query = q;
    }
    
    public T getQuery() {
    	return query ;
    }
    
    public int getPageLength() {
        return pageLength;
    }

    public void setPageLength(int pageLength) { 
        this.pageLength = pageLength;
        resetFrom();
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
        if(this.pageNo<1){
            this.pageNo=1;
        }
    }

    public void resetFrom(){
        from=(pageNo-1)*pageLength;
    }

    public int getFrom(){
        return from;
    }
    
    public void verify() {
    	if(pageNo<1) {
    		pageNo = 1;
    	}
    	if(pageLength<1) {
    		pageLength = 1;
    	}
    	resetFrom();
    }
}
